package com.siemens.industrial.model.partner;

import org.springframework.jdbc.core.RowMapper;

import java.util.Date;

/**
 * Created by weig on 8/23/16.
 */
public class Device {
    private String deviceId;
    private String deviceUniqueId;
    private String deviceModel;
    private String deviceType;
    private String line;
    private String serviceAddress;
    private String description;
    private String deviceManufactory;
    private String deviceImg;
    private Date createTime;
    private Date deleteTime;
    private Date lastHeartbeatTime;
    private String deviceName;
    private String group;
    private String purchaseDate;

    private static final RowMapper<Device> rowMapper = (resultSet, i) -> {
        Device device = new Device();
        device.setDeviceId(resultSet.getString("device_id"));
        device.setDeviceUniqueId(resultSet.getString("device_unique_id"));
        device.setDeviceModel(resultSet.getString("device_model"));
        device.setDeviceType(resultSet.getString("device_type"));
        device.setLine(resultSet.getString("line"));
        device.setCreateTime(new Date(resultSet.getTimestamp("create_time").getTime()));
        device.setDeleteTime(resultSet.getTimestamp("delete_time") == null ? null : new Date(resultSet.getTimestamp("delete_time").getTime()));
        device.setServiceAddress(resultSet.getString("service_address"));
        device.setLastHeartbeatTime(resultSet.getTimestamp("last_heartbeat_time") == null ? null : new Date(resultSet.getTimestamp("last_heartbeat_time").getTime()));
        device.setDescription(resultSet.getString("description"));
        device.setDeviceImg(resultSet.getString("device_img"));
        device.setDeviceManufactory(resultSet.getString("device_manufactory"));
        device.setDeviceName(resultSet.getString("device_name"));
        device.setGroup(resultSet.getString("group"));
        device.setPurchaseDate(resultSet.getString("purchase_date"));
        return device;
    };

    public static RowMapper<Device> getRowMapper() {
        return rowMapper;
    }

    //<editor-fold desc="getters and setters">

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public String getDeviceUniqueId() {
        return deviceUniqueId;
    }

    public void setDeviceUniqueId(String deviceUniqueId) {
        this.deviceUniqueId = deviceUniqueId;
    }

    public String getDeviceModel() {
        return deviceModel;
    }

    public void setDeviceModel(String deviceModel) {
        this.deviceModel = deviceModel;
    }

    public String getDeviceType() {
        return deviceType;
    }

    public void setDeviceType(String deviceType) {
        this.deviceType = deviceType;
    }

    public String getLine() {
        return line;
    }

    public void setLine(String line) {
        this.line = line;
    }

    public String getServiceAddress() {
        return serviceAddress;
    }

    public void setServiceAddress(String serviceAddress) {
        this.serviceAddress = serviceAddress;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getDeleteTime() {
        return deleteTime;
    }

    public void setDeleteTime(Date deleteTime) {
        this.deleteTime = deleteTime;
    }

    public Date getLastHeartbeatTime() {
        return lastHeartbeatTime;
    }

    public void setLastHeartbeatTime(Date lastHeartbeatTime) {
        this.lastHeartbeatTime = lastHeartbeatTime;
    }

    public String getDeviceManufactory() {
        return deviceManufactory;
    }

    public void setDeviceManufactory(String deviceManufactory) {
        this.deviceManufactory = deviceManufactory;
    }

    public String getDeviceImg() {
        return deviceImg;
    }

    public void setDeviceImg(String deviceImg) {
        this.deviceImg = deviceImg;
    }

    public String getDeviceName() {
        return deviceName;
    }

    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }

    public String getGroup() {
        return group;
    }

    public void setGroup(String group) {
        this.group = group;
    }

    public String getPurchaseDate() {
        return purchaseDate;
    }

    public void setPurchaseDate(String purchaseDate) {
        this.purchaseDate = purchaseDate;
    }

    //</editor-fold>
}
